//
//  HomeViewController.m
//  wtshoppingcite
//
//  Created by TW on 14-10-17.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "HomeViewController.h"
#import "JPButton.h"
#import "CustomSearchTextField.h"
#import "JVButton.h"
#import "HDScrollview.h"
#import "CustomTableView.h"
#import "NetServiseCommonData.h"
#import "RepairHistoryListViewController.h"
#import "ActivityCallUpViewController.h"
#import "NearDetailViewController.h"
#import "MMDownMenu.h"
#import "RegisterHelper.h"
#import "BannerModel.h"
#import "NoticeViewController.h"
#import "CitesViewController.h"
#import "PropertyFeeViewController.h"

#import "HomemakingViewController.h"
#import "HomeOrderViewController.h"
#import "InvestmentViewController.h"

#import "NearByTableView.h"
#import "ShopperModel.h"
#import "ShopperViewController.h"
#import "TelecomViewController.h"
#import "AdViewController.h"
#import "YaoYiYaoViewController.h"


@interface HomeViewController ()<CustomTabItemViewDelegate,UITextFieldDelegate,HDScrollviewDelegate,CustomTableViewDelegate,UIScrollViewDelegate,MMDownMenuDelegate>
{
    NSString *pageNum;
}
@property(nonatomic,strong) CustomTabItemView * tabItemView;
@property(nonatomic,strong) CustomSearchTextField* searchText;
@property(nonatomic,strong) UIScrollView* mainScrollView;
@property(nonatomic,strong) UIView* fucButtonView;
@property(nonatomic,strong) HDScrollview* advScrollView;
@property(nonatomic,strong) UIView* favShowView;
@property(nonatomic,strong) CustomTableView* doYouLoveTableView;

@property(nonatomic,strong) NSArray* dataSource;
@property(nonatomic,strong) NSMutableArray *bannerArray;


@property(nonatomic,strong) NearByTableView *nearByTableView;
@property(nonatomic,strong) NSMutableArray *dataArray;
@property(nonatomic,assign) NetworkStatus status;
@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if ([RegisterHelper shareHelper].citesName.length == 0 || [[RegisterHelper shareHelper].citesName isEqualToString:@"(null)"] || [[RegisterHelper shareHelper].citesName isEqualToString:@"<null>"]) {
        [RegisterHelper shareHelper].citesName = @"名优社区";
        [RegisterHelper shareHelper].citesId = @"2";
    }
    
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
    // Do any additional setup after loading the view.
    _bannerArray = [[NSMutableArray alloc]initWithCapacity:1];
    
    CGRect rect = [[JPButton alloc]titleRectForContentRect:CGRectMake(0, 0, 120, 40)];
    JPButton* leftNavButton = [[JPButton alloc]initWithFrame:rect];
    [leftNavButton setTitle:[RegisterHelper shareHelper].citesName forState:UIControlStateNormal];
    [leftNavButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [leftNavButton setBackgroundColor:[UIColor clearColor]];
    [leftNavButton setImage:[UIImage imageNamed:@"arrows"] forState:UIControlStateNormal];
    [leftNavButton addTarget:self action:@selector(leftClick:) forControlEvents:UIControlEventTouchUpInside];
    leftNavButton.titleLabel.font = [UIFont systemFontOfSize:15];
    leftNavButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    UIBarButtonItem* barItem = [[UIBarButtonItem alloc] initWithCustomView:leftNavButton];
    self.navigationItem.leftBarButtonItem = barItem;
    
    
    CGFloat weith = [UIUtility getLabelWidthOfText:[RegisterHelper shareHelper].citesName andFont:[UIFont systemFontOfSize:15]];
    leftNavButton.width = weith+25;
    
    NSLog(@"weith:%f",weith);
    //签到
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(0,0,80,40);
    [rightButton setTitle:@"签到" forState:UIControlStateNormal];
    rightButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [rightButton addTarget:self action:@selector(rightButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [rightButton setTitleEdgeInsets:UIEdgeInsetsMake(2, 50, 0, 0)];
    rightButton.titleLabel.textAlignment = NSTextAlignmentRight;
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightItem;

    
    _mainScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0)];
    _mainScrollView.showsHorizontalScrollIndicator = NO;
    _mainScrollView.showsVerticalScrollIndicator = NO;
    _mainScrollView.backgroundColor = [UIColor whiteColor];
    //[self.view addSubview:_mainScrollView];
    
    _dataArray = [[NSMutableArray alloc]initWithCapacity:1];
    
    
    pageNum = @"0";
    [self getShoppingList:NO];
    
    [self initAdvScrollView];
    [self initButtonView];
    [self initFavShowView];
   
    
    _mainScrollView.height = self.favShowView.height+self.fucButtonView.height+self.advScrollView.height+20;
    
    [self initTableView];
    
//    [_mainScrollView setContentSize:CGSizeMake(SCREEN_WIDTH, 600)];
    
    [self netWorkStatus];
    
    [self getAdvise];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PushMessageFlog:) name:@"GetMessageFlag" object:nil];

}


-(void)PushMessageFlog:(NSNotification*)not{
    
    //物业：2000
    //{"content":"23952927550865439","msgType":"2000"}
   
    NSDictionary* dic = [not userInfo];
    NSString* msgType = [dic objectForKey:@"msgType"];
    
    switch (msgType.integerValue) {
            //物业
        case 2000:
        {
            JVButton* button = (JVButton*)[_fucButtonView viewWithTag:303];
            
            UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(button.right - 20, button.top + 10, 10, 10)];
            imageView.tag = 2000;
            [imageView.layer setCornerRadius:5];
            [imageView clipsToBounds];
            [imageView setBackgroundColor:[UIColor redColor]];
            [_fucButtonView addSubview:imageView];
            
        }
            break;
        
        default:
            break;
    }
    
    
}


-(void)netWorkStatus{
    
    _status = [NetWorkService networkStatus];
    switch (_status) {
        case NotReachable:
            
            //NSLog(@"当前网络不可用");
            [self showToastMessage:@"当前网络不可用"];
            break;
        case ReachableViaWWAN:
            
            //NSLog(@"使用3G网络");
            [self showToastMessage:@"当前使用3G网络"];
            break;
        case ReachableViaWiFi:
            
            //NSLog(@"使用WiFi网络");
            [self showToastMessage:@"当前使用WiFi网络"];
            
            break;
    }
    
}

//每日签到
-(void)rightButtonAction:(UIButton *)sender{
    
   // __weak HomeViewController *weak_self = self;
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
    
    SetValueForKey(listDic,[RegisterHelper shareHelper].userId, @"userId");
    
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kSign
                             andHttpMethod:@"POST"
                             andParameters:listDic
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {

                         request.requestCache = YES;
                         
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                             DLog(@"成功数据:%@",responseDic);
                            
                             NSInteger result = [[responseDic objectForKey:@"result"] integerValue];
                             if (result == -1) {
                                 
                                 [self showToastMessage:@"请先登录"];
                                 return ;
                                 
                             }else{
                                 
                                 [self showToastMessage:[responseDic objectForKey:@"msg"]];
                             }
                         }
                     }];
                  
    
}

-(void)initButtonView{
    
    _fucButtonView = [[UIView alloc] initWithFrame:CGRectMake(0, _advScrollView.bottom+10, SCREEN_WIDTH, 160)];
    _fucButtonView.backgroundColor = [UIColor whiteColor];
    [_mainScrollView addSubview:_fucButtonView];
    
      NSArray* colors = @[@"xiu",@"jiao",@"tousu",@"tongzhi",@"dianxin",@"jiazheng",@"licai",@"health"];
//      NSArray* colors = @[COLOR_RGB(253, 126, 53),COLOR_RGB(253, 81, 87),COLOR_RGB(151, 156, 252),COLOR_RGB(61, 204, 155),COLOR_RGB(31, 128, 201),COLOR_RGB(39, 205, 253),COLOR_RGB(252, 176, 59),COLOR_RGB(244, 92, 144)];
    NSArray* titles = @[@"报修",@"缴费",@"意见反馈",@"小区通知",@"通信服务",@"家政服务",@"妈妈理财",@"健康医疗"];
    
//    NSArray* colors = @[@"tongzhi",@"jiao",@"huodon",@"xiu"];
//    NSArray* titles = @[@"物业通知",@"投诉记录",@"表扬记录",@"报修"];
    
    float ff = 8;
    float ox = 10;
    float oy = 5;
    float fw = (SCREEN_WIDTH - 4*ox)/4;
    float fh = 70;
    for(int i = 0; i<8;i++){
        ox =(i%4*fw)+(i%4+1)*ff;
        if(i%4 == 0 && i!=0){
            oy = oy+fh+5;
        }
        JVButton *button = [JVButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(ox, oy, fw, fh);
        [button setTitle:titles[i] forState:UIControlStateNormal];
        [button setTitleColor:MAIN_BLACK_COLOR forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        [button setImage:[UIImage imageNamed:colors[i]] forState:UIControlStateNormal];
        button.tag = 300+i;
        [button addTarget:self action:@selector(pressClick:) forControlEvents:UIControlEventTouchUpInside];
        [_fucButtonView addSubview:button];
    }
}

-(void)initAdvScrollView{
    
    NSMutableArray* imageArray = [NSMutableArray new];
    //xs
    CGRect bound=CGRectMake(0, 0, kWidth, 150);
    
    NSMutableArray  *ImageArr = [[NSMutableArray alloc]initWithCapacity:1];
    

    for (BannerModel *banner in _bannerArray) {
        [ImageArr addObject:banner.imgPath];
    }
    
    for (int i=0; i<ImageArr.count; i++) {
        UIImageView *imageview=[[UIImageView alloc]init];
        [imageview setImageWithURL:[NSURL URLWithString:[ImageArr objectAtIndex:i]] placeholderImage:[UIImage imageNamed:@"adv_bg"]];
        [imageArray addObject:imageview];
    }
    if(imageArray.count == 0){
        return;
    }
    
    [_advScrollView removeFromSuperview];
    
    _advScrollView=[[HDScrollview alloc]initLoopScrollWithFrame:bound withImageView:imageArray];
    _advScrollView.delegate=self;
    _advScrollView.HDdelegate=self;
    [_mainScrollView addSubview:_advScrollView];
    _advScrollView.pagecontrol.frame=CGRectMake((kWidth -120)/2, _advScrollView.bottom-20, 120, 10);
    _advScrollView.pagecontrol.currentcolor=[UIColor colorWithRed:77/255.0 green:77/255.0 blue:77/255.0 alpha:1];
    _advScrollView.pagecontrol.othercolor=[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1];
    _advScrollView.pagecontrol.currentPage=0;
    [_mainScrollView addSubview:_advScrollView.pagecontrol];
    
    
}

-(void)initFavShowView{
    
    _favShowView = [[UIView alloc] initWithFrame:CGRectMake(0, _fucButtonView.bottom+10, SCREEN_WIDTH, 120)];
    _favShowView.backgroundColor = [UIColor whiteColor];
    [_mainScrollView addSubview:_favShowView];
    
    
    UIView *seperateLine = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 10)];
    seperateLine.backgroundColor = COLOR_RGB(228, 229, 228);
    [_favShowView addSubview:seperateLine];
    
    UIView *upLine = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 0.3)];
    upLine.backgroundColor =MAIN_GRAY_COLOR;
    [_favShowView addSubview:upLine];
   
    UIView *downLine = [[UIView alloc]initWithFrame:CGRectMake(0, 10-0.3, kWidth, 0.3)];
    downLine.backgroundColor =MAIN_GRAY_COLOR;
    [_favShowView addSubview:downLine];
    
    UIImageView *shakeView = [[UIImageView alloc]initWithFrame:CGRectMake(5, seperateLine.bottom+10, kWidth/2+10, 40)];
    shakeView.image = [UIImage imageNamed:@"shake_win"];
    [_favShowView addSubview:shakeView];
    
    UIButton *shareButton =[[UIButton alloc]initWithFrame:CGRectMake(10, shakeView.bottom+15, shakeView.width-15, 40)];
    shareButton.clipsToBounds = YES;
    shareButton.layer.cornerRadius = 10;
    [shareButton setBackgroundColor:MAIN_BLUE_COLOR];
    [shareButton setTitle:@"立即参与" forState:UIControlStateNormal];
    [shareButton addTarget:self action:@selector(takeAction) forControlEvents:UIControlEventTouchUpInside];
    [shareButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_favShowView addSubview:shareButton];
    
    UIImageView *shakeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(shakeView.right+15, shakeView.top, kWidth/2-35, 110)];
    shakeImageView.image = [UIImage imageNamed:@"shake_home"];
    [_favShowView addSubview:shakeImageView];
}

-(void)initTableView{
    
    _doYouLoveTableView = [[CustomTableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-self.tabItemView.height - 64 - 44) type:TAB_ITEM_TYPE_DOYOULOVELIST];
    _doYouLoveTableView.tableViewDelegate = self;
    _doYouLoveTableView.isNeedTorefresh = NO;
    [self.view addSubview:_doYouLoveTableView];
    _doYouLoveTableView.tableHeaderView = _mainScrollView;
    
}

#pragma mark 立即参与
-(void)takeAction{
    
    __weak HomeViewController *weak_self = self;
    if ([AppDelegate sharedDelegate].isLogin) {
        
        YaoYiYaoViewController *yaoyiyaoVC = [[YaoYiYaoViewController alloc]init];
        yaoyiyaoVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:yaoyiyaoVC animated:YES];
        
    }else{
        
        [weak_self showToastMessage:@"请先登录"];
    }
   
}

#pragma mark advise
-(void)getAdvise{
    
    NSString *cid = [RegisterHelper shareHelper].citesId;
    
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
    SetValueForKey(listDic, cid, @"cid");
    
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                                                  andAPISuffix:kBanner
                                                 andHttpMethod:@"POST"
                                                 andParameters:listDic
                                               andRequestCache:NO
                                                andUseParamDic:YES
                                           andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                                         andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                                             
                                             [_doYouLoveTableView doneLoadingTableViewData];
                                             [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:0.5];
                                             
                                             if (response.isError) {
                                                 
                                                 DLog(@"error %@",response.errorMessage);
                                                 
                                             }else{
                                                 
                                                 NSDictionary *responseDic = request.responseJSON;
                                                 DLog(@"成功数据:%@",responseDic);
                                                NSArray *list = [responseDic objectForKey:@"ads"];
                                                     
                                            for (NSDictionary *dic in list) {
                                                         
                                                BannerModel *bannerModel = [[BannerModel alloc]initWithBInfo:dic];
                                                [_bannerArray addObject:bannerModel];
                                                
                                                [self initAdvScrollView];
                                                _fucButtonView.top = _advScrollView.bottom;
                                                _favShowView.top = _fucButtonView.bottom;
                                                
                                                _mainScrollView.height = self.favShowView.height+self.fucButtonView.height+self.advScrollView.height+20;
                                                
                                                _doYouLoveTableView.tableHeaderView = nil;
                                                _doYouLoveTableView.tableHeaderView = _mainScrollView;
                                            }
                                             
                                             }
                                             
                                         }];
}

#pragma mark CustomTabItemViewDelegate
- (void)tabItemSelectedAtIndex:(int)index tabItem:(CustomTabItemView *)view
{
    
}
-(void)tableViewSelectedWithCellData:(id)cellData indexPath:(NSIndexPath *)indexPath tableView:(CustomTableView *)tableView{
    
    ShopperModel *shopperModel = self.dataArray[indexPath.row];
    
    ShopperViewController *shopperVC = [[ShopperViewController alloc]init];
    shopperVC.hidesBottomBarWhenPushed = YES;
    shopperVC.shopId = shopperModel.shopId;
    [self.navigationController pushViewController:shopperVC animated:YES];
}

-(void)leftClick:(JPButton*)button{
        
//    VisitorViewController *visitorVC = [[NSBundle mainBundle]loadNibNamed:@"VisitorViewController" owner:self options:nil][0];
//    visitorVC.hidesBottomBarWhenPushed = YES;
//    [self.navigationController pushViewController:visitorVC animated:YES];
    
    CitesViewController *citesVC = [[CitesViewController alloc]init];
    citesVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:citesVC animated:YES];

    
}


-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"PageOne"];
   
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
     [MobClick endLogPageView:@"PageOne"];
}

#pragma textFieldDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    
    return YES;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self searchResult:textField.text];
    [textField resignFirstResponder];
    return YES;
}

-(void)searchResult:(NSString*)result{
    if(result == nil || [result isEqualToString:@""])
        return;
    //TODO
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark ==========UIScrollViewDelegate============

- (void)scrollViewDidScroll:(UIScrollView *)sender
{
    [_advScrollView HDscrollViewDidScroll];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)_scrollView
{
    [_advScrollView HDscrollViewDidEndDecelerating];
}

-(void)TapView:(int)index
{
    NSLog(@"点击了第%d个页面",index);
    //    //下面可以根据自己的需求操作
    BannerModel *bannerModel = _bannerArray[index];
    
    AdViewController *adVC = [[AdViewController alloc]init];
    adVC.hidesBottomBarWhenPushed = YES;
    adVC.urlString = bannerModel.content;
    
     NSLog(@"点击了第%@个页面",adVC.urlString);
    [self.navigationController pushViewController:adVC animated:YES];
    
}

-(void)pressClick:(JVButton*)button{
    NSInteger index = button.tag -300;
    switch (index) {
        case 0:{
            //报修
            
            if (![APP_DELEGATE isLogin]) {
                
                [APP_DELEGATE pushLoginViewControllerWithStoryBoardIdentifier:@"LoginViewController" pushIn:self];
                
            }else{
                
                RepairHistoryListViewController* repairHistoryVC = [[RepairHistoryListViewController alloc] init];
                repairHistoryVC.hidesBottomBarWhenPushed = YES;
                repairHistoryVC.type = NSBlueViewControllerRepairStyle;
                [[ConfigData sharedInstance] setBlueHomeType:NSBlueViewControllerRepairStyle];
                [self.navigationController pushViewController:repairHistoryVC animated:YES];
            }
            
        }
            break;
        case 1:{
            
            //物业缴费
            
            if (![APP_DELEGATE isLogin]) {
                
                [APP_DELEGATE pushLoginViewControllerWithStoryBoardIdentifier:@"LoginViewController" pushIn:self];
                
            }else{
                
                PropertyFeeViewController *propertFeeVC = [[PropertyFeeViewController alloc]init];
                propertFeeVC.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:propertFeeVC animated:YES];
                
            }
        }break;
        case 2:{
            
            //投诉
            
            if (![APP_DELEGATE isLogin]) {
                
                [APP_DELEGATE pushLoginViewControllerWithStoryBoardIdentifier:@"LoginViewController" pushIn:self];
                
            }else{
                
                RepairHistoryListViewController* repairHistoryVC = [[RepairHistoryListViewController alloc] init];
                repairHistoryVC.type = NSBlueViewControllerComplainStyle;
                [[ConfigData sharedInstance] setBlueHomeType:NSBlueViewControllerComplainStyle];
                repairHistoryVC.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:repairHistoryVC animated:YES];
            }

        }break;
        case 3:{
            
            //小区通知
            
            if (![APP_DELEGATE isLogin]) {
                
                [APP_DELEGATE pushLoginViewControllerWithStoryBoardIdentifier:@"LoginViewController" pushIn:self];
                
            }else{
            
                UIImageView* imageView = (UIImageView*)[_fucButtonView viewWithTag:2000];
                [imageView removeFromSuperview];
                imageView = nil;
                
                NoticeViewController *noticeVC = [[NoticeViewController alloc]init];
                noticeVC.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:noticeVC animated:YES];
            
            }
            
        }break;
        case 4:{
            //活动
//            ActivityCallUpViewController* activityCallUpVC = [[ActivityCallUpViewController alloc] init];
//            activityCallUpVC.hidesBottomBarWhenPushed = YES;
//            [self.navigationController pushViewController:activityCallUpVC animated:YES];
            
            //电信
            TelecomViewController *telecomVC = [[TelecomViewController alloc]init];
            telecomVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:telecomVC animated:YES];
            
        }break;
        case 5:{
            
//            //表扬
//            RepairHistoryListViewController* repairHistoryVC = [[RepairHistoryListViewController alloc] init];
//            repairHistoryVC.type = NSBlueViewControllerPraiseStyle;
//            [[ConfigData sharedInstance] setBlueHomeType:NSBlueViewControllerPraiseStyle];
//            repairHistoryVC.hidesBottomBarWhenPushed = YES;
//            [self.navigationController pushViewController:repairHistoryVC animated:YES];
            
            //家政服务
            HomemakingViewController  *homeMakingVC = [[HomemakingViewController alloc]init];
            homeMakingVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:homeMakingVC animated:YES];
            
        }break;
        case 6:{
            
            //投资理财
            InvestmentViewController  *investmentVC = [[InvestmentViewController alloc]init];
            investmentVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:investmentVC animated:YES];
            
        }break;
        case 7:{
            
            //健康医疗

            HomeOrderViewController  *homeOrderVC = [[HomeOrderViewController alloc]init];
            homeOrderVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:homeOrderVC animated:YES];
            
        }break;
        default:
            break;
    }
    
}

#pragma mark getShoppingList 安心商家
-(void)getShoppingList:(BOOL)isMore{
    
    NSString *page = pageNum;
    NSString *pageSize = @"10";
    NSString *cid = [[RegisterHelper shareHelper]citesId];
    
  
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
    
    SetValueForKey(listDic, cid, @"cid");
    SetValueForKey(listDic, page, @"page");
    SetValueForKey(listDic, pageSize, @"pageSize");
    
    [self showLoadImageView:self.view subview:_nearByTableView];
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                                            andAPISuffix:kshoplist
                                           andHttpMethod:@"POST"
                                           andParameters:listDic
                                         andRequestCache:NO
                                          andUseParamDic:YES
                                     andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                                   andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                                       [_nearByTableView doneLoadingTableViewData];
                                       [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:0.5];
                                       
                                       request.requestCache = YES;
                                       
                                       if (response.isError) {
                                           
                                           DLog(@"error %@",response.errorMessage);
                                           
                                       }else{
                                           
                                           NSDictionary *responseDic = request.responseJSON;
                                           DLog(@"成功数据:%@",responseDic);
                                           
                                           NSArray *list = [responseDic objectForKey:@"list"];
                                           if (list.count < 10) {
                                               _doYouLoveTableView.isMore = NO;
                                           }else{
                                               _doYouLoveTableView.isMore = YES;
                                               
                                               int currentPage = [pageNum intValue];
                                               pageNum = [NSString stringWithFormat:@"%d",currentPage+1];
                                               
                                           }
                                           if (!isMore) {
                                               [_dataArray removeAllObjects];
                                           }
                                           for (NSDictionary *dic in list) {
                                               ShopperModel *shoppingModel = [[ShopperModel alloc]initWithShopperInfo:dic];
                                               [_dataArray addObject:shoppingModel];
                                           }
                                           _doYouLoveTableView.tableViewDataSource = _dataArray;
                                           [RegisterHelper shareHelper].type = PurchaseSingleStyle;
                                       }
                                
                                       [_doYouLoveTableView reloadData];
                                       
                                   }];
    
}

#pragma mark  eventsDelegate
- (void)pullUp:(BaseTableView *)baseTableView{

    [self getShoppingList:YES];
  
}

- (void)pullDown:(BaseTableView *)baseTableView{
    
    pageNum = @"0";
    [self getShoppingList:NO];
  
    
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
